package com.changgou.system.Filter;

import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.stereotype.Component;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

@Component
public class IpFilter implements GlobalFilter, Ordered {


    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {

        //获取客户端的访问ip
        System.out.println("这是第一个过滤器IpFilter");
        String hostName = exchange.getRequest().getRemoteAddress().getHostName();
        return chain.filter(exchange);

    }

    @Override
    public int getOrder() {
        return 1;
    }
}
